home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Tool Chest / Development Kits / MPW etc. / MPW-PR / Interfaces&Libraries / Interfaces / CIncludes / MachineExceptions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-17  |  6.6 KB  |  247 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        MachineExceptions.h
  3.  
  4.      Contains:    Processor Exception Handling Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    Universal Interfaces 3.1 for AltiVec
  8.  
  9.      Copyright:    © 1993-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __MACHINEEXCEPTIONS__
  19. #define __MACHINEEXCEPTIONS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=power
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. /* Some basic declarations used throughout the kernel */
  48. typedef struct OpaqueAreaID*             AreaID;
  49. #if TARGET_OS_MAC
  50. /* Machine Dependent types for PowerPC: */
  51.  
  52. struct MachineInformationPowerPC {
  53.     UnsignedWide                     CTR;
  54.     UnsignedWide                     LR;
  55.     UnsignedWide                     PC;
  56.     unsigned long                     CR;
  57.     unsigned long                     XER;
  58.     unsigned long                     MSR;
  59.     unsigned long                     MQ;
  60.     unsigned long                     ExceptKind;
  61.     unsigned long                     DSISR;
  62.     UnsignedWide                     DAR;
  63.     UnsignedWide                     Reserved;
  64. };
  65. typedef struct MachineInformationPowerPC MachineInformationPowerPC;
  66.  
  67. struct RegisterInformationPowerPC {
  68.     UnsignedWide                     R0;
  69.     UnsignedWide                     R1;
  70.     UnsignedWide                     R2;
  71.     UnsignedWide                     R3;
  72.     UnsignedWide                     R4;
  73.     UnsignedWide                     R5;
  74.     UnsignedWide                     R6;
  75.     UnsignedWide                     R7;
  76.     UnsignedWide                     R8;
  77.     UnsignedWide                     R9;
  78.     UnsignedWide                     R10;
  79.     UnsignedWide                     R11;
  80.     UnsignedWide                     R12;
  81.     UnsignedWide                     R13;
  82.     UnsignedWide                     R14;
  83.     UnsignedWide                     R15;
  84.     UnsignedWide                     R16;
  85.     UnsignedWide                     R17;
  86.     UnsignedWide                     R18;
  87.     UnsignedWide                     R19;
  88.     UnsignedWide                     R20;
  89.     UnsignedWide                     R21;
  90.     UnsignedWide                     R22;
  91.     UnsignedWide                     R23;
  92.     UnsignedWide                     R24;
  93.     UnsignedWide                     R25;
  94.     UnsignedWide                     R26;
  95.     UnsignedWide                     R27;
  96.     UnsignedWide                     R28;
  97.     UnsignedWide                     R29;
  98.     UnsignedWide                     R30;
  99.     UnsignedWide                     R31;
  100. };
  101. typedef struct RegisterInformationPowerPC RegisterInformationPowerPC;
  102.  
  103. struct FPUInformationPowerPC {
  104.     UnsignedWide                     Registers[32];
  105.     unsigned long                     FPSCR;
  106.     unsigned long                     Reserved;
  107. };
  108. typedef struct FPUInformationPowerPC    FPUInformationPowerPC;
  109.  
  110. union Vector128 {
  111. #ifdef __VEC__
  112.     vector unsigned long            v;
  113. #endif
  114.     unsigned long                     l[4];
  115.     unsigned short                     s[8];
  116.     unsigned char                     c[16];
  117. };
  118. typedef union Vector128                    Vector128;
  119.  
  120. struct VectorInformationPowerPC {
  121.     Vector128                         Registers[32];
  122.     Vector128                         VSCR;
  123.     UInt32                             VRsave;
  124. };
  125. typedef struct VectorInformationPowerPC    VectorInformationPowerPC;
  126. /* Exception related declarations */
  127.  
  128. enum {
  129.     kWriteReference                = 0,
  130.     kReadReference                = 1,
  131.     kFetchReference                = 2,
  132.     writeReference                = kWriteReference,                /* Obsolete name*/
  133.     readReference                = kReadReference,                /* Obsolete name*/
  134.     fetchReference                = kFetchReference                /* Obsolete name*/
  135. };
  136.  
  137.  
  138. typedef unsigned long                     MemoryReferenceKind;
  139.  
  140. struct MemoryExceptionInformation {
  141.     AreaID                             theArea;
  142.     LogicalAddress                     theAddress;
  143.     OSStatus                         theError;
  144.     MemoryReferenceKind             theReference;
  145. };
  146. typedef struct MemoryExceptionInformation MemoryExceptionInformation;
  147.  
  148. enum {
  149.     kUnknownException            = 0,
  150.     kIllegalInstructionException = 1,
  151.     kTrapException                = 2,
  152.     kAccessException            = 3,
  153.     kUnmappedMemoryException    = 4,
  154.     kExcludedMemoryException    = 5,
  155.     kReadOnlyMemoryException    = 6,
  156.     kUnresolvablePageFaultException = 7,
  157.     kPrivilegeViolationException = 8,
  158.     kTraceException                = 9,
  159.     kInstructionBreakpointException = 10,
  160.     kDataBreakpointException    = 11,
  161.     kIntegerException            = 12,
  162.     kFloatingPointException        = 13,
  163.     kStackOverflowException        = 14,
  164.     kTaskTerminationException    = 15,
  165.     kTaskCreationException        = 16
  166. };
  167.  
  168. #if OLDROUTINENAMES
  169.  
  170. enum {
  171.     unknownException            = kUnknownException,            /* Obsolete name*/
  172.     illegalInstructionException    = kIllegalInstructionException,    /* Obsolete name*/
  173.     trapException                = kTrapException,                /* Obsolete name*/
  174.     accessException                = kAccessException,                /* Obsolete name*/
  175.     unmappedMemoryException        = kUnmappedMemoryException,        /* Obsolete name*/
  176.     excludedMemoryException        = kExcludedMemoryException,        /* Obsolete name*/
  177.     readOnlyMemoryException        = kReadOnlyMemoryException,        /* Obsolete name*/
  178.     unresolvablePageFaultException = kUnresolvablePageFaultException, /* Obsolete name*/
  179.     privilegeViolationException    = kPrivilegeViolationException,    /* Obsolete name*/
  180.     traceException                = kTraceException,                /* Obsolete name*/
  181.     instructionBreakpointException = kInstructionBreakpointException, /* Obsolete name*/
  182.     dataBreakpointException        = kDataBreakpointException,        /* Obsolete name*/
  183.     integerException            = kIntegerException,            /* Obsolete name*/
  184.     floatingPointException        = kFloatingPointException,        /* Obsolete name*/
  185.     stackOverflowException        = kStackOverflowException,        /* Obsolete name*/
  186.     terminationException        = kTaskTerminationException,    /* Obsolete name*/
  187.     kTerminationException        = kTaskTerminationException        /* Obsolete name*/
  188. };
  189.  
  190. #endif  /* OLDROUTINENAMES */
  191.  
  192.  
  193. typedef unsigned long                     ExceptionKind;
  194.  
  195. union ExceptionInfo {
  196.     MemoryExceptionInformation *    memoryInfo;
  197. };
  198. typedef union ExceptionInfo                ExceptionInfo;
  199.  
  200. struct ExceptionInformationPowerPC {
  201.     ExceptionKind                     theKind;
  202.     MachineInformationPowerPC *        machineState;
  203.     RegisterInformationPowerPC *    registerImage;
  204.     FPUInformationPowerPC *            FPUImage;
  205.     ExceptionInfo                     info;
  206.     VectorInformationPowerPC *        vectorImage;
  207. };
  208. typedef struct ExceptionInformationPowerPC ExceptionInformationPowerPC;
  209.  
  210. typedef ExceptionInformationPowerPC     ExceptionInformation;
  211. typedef MachineInformationPowerPC         MachineInformation;
  212. typedef RegisterInformationPowerPC         RegisterInformation;
  213. typedef FPUInformationPowerPC             FPUInformation;
  214. typedef VectorInformationPowerPC         VectorInformation;
  215. /* 
  216.     Note:    An ExceptionHandler is NOT a UniversalProcPtr.
  217.             It must be a PowerPC function pointer with NO routine descriptor. 
  218. */
  219. typedef CALLBACK_API_C( OSStatus , ExceptionHandler )(ExceptionInformationPowerPC *theException);
  220. /* Routine for installing per-process exception handlers */
  221. EXTERN_API( ExceptionHandler ) InstallExceptionHandler(ExceptionHandler theHandler);
  222.  
  223. #endif  /* TARGET_OS_MAC */
  224.  
  225.  
  226.  
  227. #if PRAGMA_STRUCT_ALIGN
  228.     #pragma options align=reset
  229. #elif PRAGMA_STRUCT_PACKPUSH
  230.     #pragma pack(pop)
  231. #elif PRAGMA_STRUCT_PACK
  232.     #pragma pack()
  233. #endif
  234.  
  235. #ifdef PRAGMA_IMPORT_OFF
  236. #pragma import off
  237. #elif PRAGMA_IMPORT
  238. #pragma import reset
  239. #endif
  240.  
  241. #ifdef __cplusplus
  242. }
  243. #endif
  244.  
  245. #endif /* __MACHINEEXCEPTIONS__ */
  246.  
  247.